﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using fsw.Common;
using System.Data;

namespace fsw.BLL
{
    public partial class Project
    {
        private readonly DAL.Project dal;
        public Project()
        {
            dal = new DAL.Project(DTKeys.DATA_BASE_PREFIX);
        }
        #region 基本操作方法================
        /// <summary>
        /// 根据id判读是否存在
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool Exists(int id)
        {
            return dal.Exists(id);
        }
        /// <summary>
        /// 根据项目名称判断是否存在
        /// </summary>
        /// <param name="HosName"></param>
        /// <returns></returns>
        public bool Exists(string HosName)
        {
            return dal.Exists(HosName);
        }
        /// <summary>
        /// 权限
        /// </summary>
        /// <param name="Userid"></param>
        /// <param name="Pid"></param>
        /// <returns></returns>
        public bool ExistsPid(int Userid, int Pid)
        {
            return dal.ExistsPid(Userid, Pid);
        }
        /// <summary>
        /// 根据项目id判断是否存在
        /// </summary>
        /// <param name="UserName"></param>
        /// <returns></returns>
        public bool ExistsPid(int Pid)
        {
            return dal.ExistsPid(Pid);
        }
        /// <summary>
        /// 添加数据
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int Add(Model.Project model)
        {
            return dal.Add(model);
        }
        /// <summary>
        /// 更新数据
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool Update(Model.Project model)
        {
            return dal.Update(model);
        }
        /// <summary>
        /// 得到一个实体
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public Model.Project GetModel(int id)
        {
            return dal.GetModel(id);
        }
         /// <summary>
        /// 根据方式网id获取项目名称
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public string GetTitle(int id)
        {
            return dal.GetTitle(id);
        }
        /// <summary>
        /// 更新数据
        /// </summary>
        /// <param name="id"></param>
        /// <param name="strValue"></param>
        /// <returns></returns>
        public bool UpdateField(int id, string strValue)
        {
            return dal.UpdateField(id, strValue);
        }
        /// <summary>
        /// 删除一条数据
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool Delete(int id)
        {
            return dal.Delete(id);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="strWhere"></param>
        /// <param name="filedOrder"></param>
        /// <returns></returns>
        public List<Model.Project> GetList(string strWhere, string filedOrder)
        {
            return dal.GetList(strWhere, filedOrder);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public List<Model.Project> GetList()
        {
            List<Model.Project> _List = new List<Model.Project>();
            _List = CacheHelper.Get<List<Model.Project>>(CacheSet.PROJECT);
            if (_List != null)
                return _List;
            return GetList("", "OrderNo desc");           
        }
        /// <summary>
        /// 分页数据
        /// </summary>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <param name="strWhere"></param>
        /// <param name="filedOrder"></param>
        /// <param name="recordCount"></param>
        /// <returns></returns>
        public DataSet GetList(int pageSize, int pageIndex, string strWhere, string filedOrder, out int recordCount)
        {
            return dal.GetList(pageSize, pageIndex, strWhere, filedOrder, out recordCount);
        }
        #endregion
    }
}
